package com.wc.blue_bridge_history.Java12Q.B_完全日期;

import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;

/**
 * @Author congge
 * @Date 2024/5/20 18:22
 * @description https://www.lanqiao.cn/problems/1562/learning/
 */
public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static int[] mod = new int[]{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    static Set<Integer> set = new HashSet<>();

    public static void main(String[] args) {
        int res = 0;
        for (int i = 1; i <= 10; i++) set.add(i * i);
        for(int i = 1; i <= 12; i++){
            res += mod[i];
        }
        out.println(res);
        res = 0;
        for (int y = 2001; y <= 2021; y++) {
            if (isRun(y)) {
                mod[2] = 29;
            } else mod[2] = 28;
            for (int m = 1; m <= 12; m++) {
                for (int d = 1; d <= mod[m]; d++) {
                    int sum = cal(y) + cal(m) + cal(d);
                    if (isSq(sum)) res++;
                }
            }
        }
        out.println(res);
        out.flush();
    }

    static int cal(int x) {
        int res = 0;
        while (x > 0) {
            res += x % 10;
            x /= 10;
        }
        return res;
    }

    static boolean isRun(int y) {
        return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
    }

    static boolean isSq(int x) {
        return set.contains(x);
    }
}
